package com.twt.survey2025springlogin.utils;

import java.util.List;

public class StaticUtils {

    // 判断 "其他___" 选项
    public static final String JUDGE_OTHER = "other.";
    public static final Integer JUDGE_LEN = 6;
    public static final Integer JUDGE_START = 0;
    public static final Integer JUDGE_END = 6;

    public static final String MARK_OTHER = "1";

    public static String[] setValue(List<String> list){
        String target = "", targetOther = "";
        if (!(list == null || list.isEmpty())){
            for (String s : list){
                if (s.length() >= StaticUtils.JUDGE_LEN){
                    if (StaticUtils.JUDGE_OTHER.equals(s.substring(StaticUtils.JUDGE_START, StaticUtils.JUDGE_END))){
                        targetOther = StaticUtils.MARK_OTHER;
                        break;
                    }
                }
            }
            target = list.toString();
        } else {
            targetOther = null;
        }

        String[] res = new String[2];
        res[0] = target;
        res[1] = targetOther;
        return res;
    }

    public static boolean judgeNull (List<String> list) {
        for (String s : list) {
            s = s.trim();
            if (s.isEmpty() || s.isBlank() || s == null) {
                return true;
            }
        }
        return false;
    }

}
